[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 FOR VAR = IEXP1 TO IEXP2 [STEP IEXP3]
 statement(s)
 NEXT

 Function
  Execute a block of statments for a range of values.
  FOR  - Initializes a loop by assigning IEXP1 to VAR and continuing
         while VAR <= IEXP2 (if IEXP3 >= 0) or VAR >= IEXP2
         (if IEXP3 < 0) (TO is required to separate IEXP1 and IEXP2;
         if STEP (optional) is not specified IEXP3 defaults to 1)
  NEXT - Adds IEXP3 to VAR, transfers control to the closest FOR
         statement, and marks the end of the FOR loop (ENDFOR and END
         FOR are synonyms)

 Syntax
  FOR var = start TO end [STEP inc]
    statement(s)
  NEXT

   var   - The index variable for the loop that will be set to each value.
   start - Any valid PPL expression.
   end   - Any valid PPL expression.
   inc   - Any valid PPL expression.  1 if not specified.

 Remarks
  A FOR loop can consist of one or more statements.  At the beginning of
  the loop the specified variable (var) is initialized to the start value.
  It is then checked against the end value.  If start is greater than end
  (for positive values of inc) or less than end (for negative values of
  inc) then the loop terminates.  Otherwise all the statements in the loop
  are executed in order.  At the NEXT statement the inc value (1 if not
  explicitly defined) is added to var and the loop value is retested as
  described above.

 Examples
  BOOLEAN p(100)
  INTEGER i
  FOR i = 1 TO 100 ' Initialize all to TRUE
   LET p(i) = TRUE
  NEXT
  LET p(1) = FALSE
  FOR i = 4 TO 100 STEP 2 ' Initialize every other one to FALSE
   LET p(i) = FALSE
  NEXT

See Also: IF/ELSE(IF)/ENDIF WHILE/ENDWHILE
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson